<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vue局部组件案例</title>
    <script src="vue.js"></script>
    <style>
        .template1 {
            border: 1px dashed black;
            border-radius: 15px;
            padding: 10px;
            width: 200px;
            height: 160px;
            text-align: center;
            float: left;
            margin-right: 50px;
            margin-bottom: 50px;
            box-shadow: 10px 10px 5px dimgray;
            background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, green), color-stop(100%, yellow));
            ;
        }

        .template2 {
            border: 1px dashed black;
            border-radius: 15px;
            padding: 10px;
            width: 200px;
            height: 250px;
            text-align: center;
            float: left;
            margin-right: 50px;
            margin-bottom: 50px;
            box-shadow: 10px 10px 5px dimgray;
            background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, green), color-stop(100%, yellow));
            ;
        }
    </style>
</head>

<body>
    <template id="t1">
        <div class="template1">
            <h3>helloworld</h3>
            <h4>蜗牛学员</h4>
        </div>
    </template>
    <template id="t2">
        <div class="template2">
            <div>
                <img src="images/xiao.jpg" alt="">
            </div>
            <div>
                <span style="font-weight:bold">{{describle}}</span>
            </div>
        </div>
    </template>

    <div id="app1">
        <div>
            <infoitem></infoitem>
            <infoitem></infoitem>
            <infoitem></infoitem>
            <infoitem></infoitem>
            <infoitem></infoitem>
        </div>
        <div>
            <imageitem></imageitem>
            <imageitem></imageitem>
            <imageitem></imageitem>
            <imageitem></imageitem>
            <imageitem></imageitem>
        </div>
    </div>

</body>

</html>
<script>

    var vm1 = new Vue({
        el: "#app1",
        //定义局部组件
        components: {
            'infoitem': { template: "#t1", },
            'imageitem': {
                template: "#t2",
                data: function () {
                    return {
                        describle: "小姐姐"
                    }
                }
            }
        },
    });
</script>